# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=gdu
pkgver=5.25.0
_majorver=${pkgver%%.*}
pkgrel=2
pkgdesc="Fast disk usage calculator with console interface"
url="https://github.com/dundee/gdu"
arch="all"
license="MIT"
makedepends="go gzip"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/dundee/gdu/archive/refs/tags/v$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	default_prepare

	rm -rf vendor/
}

build() {
	local versionflags
	versionflags="
	-X github.com/dundee/gdu/v$_majorver/build.Version=$pkgver
	-X github.com/dundee/gdu/v$_majorver/build.User=buildozer
	-X 'github.com/dundee/gdu/v$_majorver/build.Time=$(date)'
	"
	go build -v \
		-ldflags="$versionflags" \
		./cmd/gdu

	gzip gdu.1
}

check() {
	go test -v ./...
}

package() {
	install -Dm0755 gdu -t "$pkgdir"/usr/bin/
	install -Dm0644 gdu.1.gz -t "$pkgdir"/usr/share/man/man1/
	install -Dm0644 LICENSE.md -t "$pkgdir"/usr/share/licenses/gdu/
}

sha512sums="
25d20304e9bfd805e0991e49b663666216d93865b91be84ef58a3b0c2ef44ed35fc59aa5a5ac15d31aea40cad3e2a920037d1a8ca75a889582ece7cff174c9dd  gdu-5.25.0.tar.gz
"
